﻿//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
// Exo² samples - Test
// Copyright (C) 2007-2009 Samuel Lacroix and Raphaël Legouge
//
// Distributed under GNU General Public License
// See the License folder of Exo² for details
//
//
// http://www.codeplex.com/exo2 (eng)
//-----------------------------------------------------------------------------
#ifndef GUI_H
#define GUI_H

namespace GUI {

// Objet qui va gèrer les empilement de menu
class CMenuManager
{
    public:
        static CMenuManager& Instance()
        {
                static CMenuManager* pInstance = NULL;
                if (!pInstance)
                    pInstance = new CMenuManager;
                return *pInstance;
        }
        
    // Entrer dans un menu
        void Enter(const tstring& MenuName);
        
    // Retourner au menu précédent
        void Back();
        
    // Retourner au menun principal
        void ReturnToMain();
        
    // Accesseur
        const tstring& GetCurrentMenuName() const;      // Nom du menu courant
        bool IsChanged() const;                         // Si on a changé de menu ou pas
        
    // Remise à zéro de la détection de changement de menu
        void ResetChangingMenu();
    
    private:
        CMenuManager() {Enter(_T("")); this->Change = false;}
        virtual ~CMenuManager() throw() {}
        CMenuManager& operator=(const CMenuManager&);
        CMenuManager(const CMenuManager&);
        
        typedef std::stack<tstring> StringStack;
        StringStack MenuStack;
        
        bool Change;
};

// Enregistrement des composants du menu
void RegisterComponents();

// CallBack de création des composants
Exo2::CMenuComponent* CreateButtonCallback(void* pUserData);
Exo2::CMenuComponent* CreateCheckBoxCallback(void* pUserData);
Exo2::CMenuComponent* CreateLabelCallback(void* pUserData);
Exo2::CMenuComponent* CreateSliderCallback(void* pUserData);
Exo2::CMenuComponent* CreateTextButtonCallback(void* pUserData);

// Nos composants :
// Boutton
class CButton : public Exo2::CMenuButton
{
    public:
        static void SetStateSpriteFileName(const tstring& FileName);
        
        static const tstring& GetStateSpriteFileName();
    
    private:
        virtual void LoadStateSprites();
        
        static tstring StateSpriteFileName;
};

// CheckBox
class CCheckBox : public Exo2::CMenuCheckBox
{
    public:
        static void SetStateSpriteFileName(const tstring& FileName);
        
        static const tstring& GetStateSpriteFileName();
    
    private:
        virtual void LoadStateSprites();
        
        static tstring StateSpriteFileName;
};

// Label
class CLabel : public Exo2::CMenuLabel
{

};

// Slider
class CSlider : public Exo2::CMenuHorizontalSlider
{
    public:
        CSlider();
        static void SetStateSpriteFileName(const tstring& FileName);
        
        static const tstring& GetStateSpriteFileName();

    private:
        virtual void LoadStateSprites();
        
        static tstring StateSpriteFileName;
};

// Boutton avec du texte
class CTextButton : public Exo2::CMenuTextButton
{
    public:
        static void SetStateSpriteFileName(const tstring& FileName);
        
        static const tstring& GetStateSpriteFileName();
    
    private:
        virtual void LoadStateSprites();
        
        static tstring StateSpriteFileName;
};

void ResetTest1();
void ResetTest2();
void ResetTest3();

// Gestion des menus
void OnClickGoToSubMenu(Exo2::CMenuComponent* pSender, void* pUserData);
void OnClickBack(Exo2::CMenuComponent* pSender, void* pUserData);

void OnClickResetTest(Exo2::CMenuComponent* pSender, void* pUserData);

// Test1
void OnClickTest1(Exo2::CMenuComponent* pSender, void* pUserData);
void OnDblClickTest1(Exo2::CMenuComponent* pSender, void* pUserData);
void OnMouseEnterTest1(Exo2::CMenuComponent* pSender, void* pUserData);
void OnMouseLeaveTest1(Exo2::CMenuComponent* pSender, void* pUserData);
void OnMouseUpTest1(Exo2::CMenuComponent* pSender, Exo2::MENU_MOUSE_BUTTON mb, long X, long Y, void* pUserData);
void OnMouseDownTest1(Exo2::CMenuComponent* pSender, Exo2::MENU_MOUSE_BUTTON mb, long X, long Y, void* pUserData);
void OnMouseMoveTest1(Exo2::CMenuComponent* pSender, long X, long Y , void* pUserData);

// Test2
void OnClickTest2(Exo2::CMenuComponent* pSender, void* pUserData);

// Test3
void OnChangeTest3(Exo2::CMenuComponent* pSender, void* pUserData);
}

#include "gui.inl"
#endif